package com.qau.zek.dao;

import com.qau.zek.pojo.goods;
import com.qau.zek.utils.JDBCUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.Connection;
import java.sql.SQLException;

public class GoodsDao {
    public goods getGoodsInformation(String name) throws SQLException {
        QueryRunner queryRunner = new QueryRunner();
        Connection connection = JDBCUtil.getConnection();
        String sql = "select * from goods where good_name=?";
        goods query = queryRunner.query(connection, sql, new BeanHandler<goods>(goods.class),name);
        return query;
    }

    public static void main(String[] args) throws SQLException {
        goods a = new GoodsDao().getGoodsInformation("a");
        System.out.println(a);
    }
}
